<template>
	<view style="background-color: #F0F0F0;">
		<view >
			<uni-card :is-full="true" >
				<view style="line-height: 60upx;">
					<view>
						<text>题目:</text>
						<rich-text :nodes="material.questionsname"></rich-text>
					</view>
					<view>
						<text>材料:</text>
						<rich-text :nodes="material.recitedata"></rich-text>
					</view>
				</view>
				<button type="default" @click="deleteDown">删除</button>
			</uni-card>
		</view>
	</view>
</template>

<script>
	import uniCard from '@/components/uni-card/uni-card.vue'

	import userApi from "@/api/user.js"

	let _this;
	export default {
		components: {
			uniCard
		},

		data() {
			return {
				query:{},
				material:{},
				
			}
		},
		onLoad(query) {
			_this = this;
			_this.query = query
			_this.initData();
			
		},
		computed: {
			
		},
		methods: {
			initData() {
				
				let downloadData = uni.getStorageSync('download')
				console.log(downloadData)
				downloadData.forEach((item,index)=>{
					if(item.questionsid == _this.query.id){
						_this.material = item
					}
				})
				
			},
			
			deleteDown(){
				let downloadData = uni.getStorageSync('download')
				
				let _index = ''
				downloadData.forEach((item,index)=>{
					if(item.questionsid == _this.query.id){
						_index  = index
					}
				})
				console.log(_index)
				downloadData.splice(_index ,1)
				console.log(downloadData)
				uni.setStorageSync('download',downloadData)
				uni.navigateBack()
			}

		}
	}
</script>

<style>
	page {
		display: flex;
		flex-direction: column;
		box-sizing: border-box;
		background-color: #fff
	}

	view {
		font-size: 28upx;
		line-height: inherit
	}

	.example {
		padding: 0 30upx 30upx
	}

	.example-title {
		font-size: 32upx;
		line-height: 32upx;
		color: #777;
		margin: 40upx 25upx;
		position: relative
	}

	.example .example-title {
		margin: 40upx 0
	}

	.example-body {
		padding: 0 40upx
	}
</style>
